import configparser
from peewee import *
config = configparser.ConfigParser()
config.read('ENV.ini')
def connect_to_sql():
    database = MySQLDatabase(
        database=config.get('db', 'db'),
        host=config.get('db', 'host'),
        port=int(config.get('db', 'port')),
        user=config.get('db', 'user'),
        password=config.get('db', 'pwd')
    )
    # 创建数据库表
    ret = database.connect()
    print("connect:", ret)
    return database
database = connect_to_sql()
